﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.GroupPolicy;

namespace ADAuthTest
{
    public class GPO
    {
        public GPO()
        {
            GPDomain domain = new GPDomain("ceibs.edu");
           
            try
            {
               
                //Som som = domain.GetSom("User Configuration/Preferences/Windows settings/Drive Maps");
                //Console.WriteLine(som.Name + som.Path + som.ContainerType.ToString());
                System.Security.SecurityManager.PolicyHierarchy();

                GPSearchCriteria search = new GPSearchCriteria();//
                search.Add(SearchProperty.GpoDisplayName, SearchOperator.Contains, @"Maps");

                GpoCollection gpos = domain.GetAllGpos();

                foreach (Gpo gpo in gpos)
                {

                    Console.WriteLine(gpo.DisplayName + "\t" + gpo.User);
                    Console.WriteLine(gpo.DomainName);
                    //Console.WriteLine(gpo.WmiFilter.Path);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            
        }
    }
}
